package com.iee.webbase.demo;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.iee.webbase.demo.mapper.AccountMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dadiyang
 * @since 2019-06-02
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {
    private final AccountMapper accountMapper;

    @Override
    public Account getById(int id) {
        return accountMapper.selectById(id);
    }

    @Override
    public int insert(Account account) {
//        int rs = accountMapper.insert(account);
        List<Account> list = Lists.newArrayList();
        for(int i = 0; i < 20000; i++){
            Account a = new Account();
            a.setId(IdWorker.getIdStr());
            a.setName("a" + i);
            a.setBalance(100D);
            this.save(a);
        }
        return 0;
    }

}
